package com.prawn.ift.ctrlequipment.controller;

import com.prawn.ift.ctrlequipment.entity.CtrlEquipmentStatusVo;
import com.prawn.ift.ctrlequipment.pojo.CtrlequipmentStatus;
import com.prawn.ift.ctrlequipment.service.CtrlEquipmentStatusService;
import entity.Result;
import entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/10/21
 * @DESC： 控制设备状态管理服务实现
 */
@Controller
public class CtrlEquipmentStatusController {

    @Autowired
    private CtrlEquipmentStatusService ctrlEquipmentStatusService;

    /**
     * 添加控制设备信息
     * @Param ctrlEquipmentStatus
     * @return Result
     */
    @RequestMapping("/ctrlequipment/status/add")
    @ResponseBody
    public Result add(CtrlequipmentStatus ctrlEquipmentStatus) {
        ctrlEquipmentStatus.setId(UUID.randomUUID().toString().replaceAll("-",""));
        ctrlEquipmentStatus.setCreateDate(new Date());
        ctrlEquipmentStatus.setUpdateDate(new Date());
        return ctrlEquipmentStatusService.addCtrlEquipmentStatus(ctrlEquipmentStatus);
    }

    /**
     * 删除控制设备信息
     * @Param id
     * @return Result
     */
    @RequestMapping("/ctrlequipment/status/delete")
    @ResponseBody
    public Result delete(String id) {
        return ctrlEquipmentStatusService.deleteCtrlEquipmentStatus(id);
    }

    /**
     * 修改控制设备信息
     * @Param
     * @return Result
     */
    @RequestMapping("/ctrlequipment/status/edit")
    @ResponseBody
    public Result edit(CtrlequipmentStatus ctrlEquipmentStatus) {
        ctrlEquipmentStatus.setCreateDate(null);
        ctrlEquipmentStatus.setUpdateDate(new Date());
        return ctrlEquipmentStatusService.editCtrlEquipmentStatus(ctrlEquipmentStatus);
    }

    /**
     * 查询控制设备信息
     * @return CtrlEquipmentStatus
     */
    @RequestMapping("/ctrlequipment/status/{id}")
    @ResponseBody
    public CtrlequipmentStatus get(@PathVariable String id) {
        return ctrlEquipmentStatusService.getCtrlEquipmentStatusById(id);
    }

    /**
     * 查询控制设备信息列表
     * @return Result
     */
    @RequestMapping("/ctrlequipment/status/list")
    @ResponseBody
    public Result getList() {
        return ctrlEquipmentStatusService.getCtrlEquipmentStatusList();
    }

    /**
     * 多条件查询控制设备信息列表
     * @return Result
     */
    @RequestMapping("/ctrlequipment/status/query")
    @ResponseBody
    public Result getListByVo(CtrlEquipmentStatusVo ctrlEquipmentStatusVo) {
        return ctrlEquipmentStatusService.getCtrlEquipmentStatusListByVo(ctrlEquipmentStatusVo);
    }

    /**
     * 分页查询控制设备信息列表
     * @return Result
     */
    @RequestMapping("/ctrlequipment/status/page")
    @ResponseBody
    public Result getPage(int page,int limit) {
        return ctrlEquipmentStatusService.getCtrlEquipmentStatusPage(page,limit);
    }

}
